/**
 * Copyright 2009 University of Washington This code is released under the GPL version 3 - with a copy of the license
 * included
 * 
 * @author Maya Hao Li
 * 
 */
package seedpod.webapp.view.htmlwidget;

import java.io.IOException;
import java.io.Writer;

public abstract class GenericHtmlWidget {
	protected static String ATT( String name, int val ) {
		return name + "=\"" + val + "\" ";
	}

	protected static String ATT( String name, String val ) {
		if ( val != null && val.length() > 0 )
			return name + "=\"" + val + "\" ";
		else return "";
	}

	protected String _cssClass = "";

	protected String _widgetID = "";

	public GenericHtmlWidget() {}

	public GenericHtmlWidget(String widgetID) {
		_widgetID = widgetID;
	}

	public String getId() {
		return _widgetID;
	}

	public abstract String render();

	public void render( Writer out ) throws IOException {
		out.write( render() );
	}

	public void setCssClass( String cssClass ) {
		_cssClass = cssClass;
	}

	public void setId( String Id ) {
		_widgetID = Id;
	}

	@Override
	public String toString() {
		return render();
	}

}